package com.cbgolf.oa.activity.coupon;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;
import com.cbgolf.oa.R;
import com.cbgolf.oa.activity.publiz.MainActivity;
import com.cbgolf.oa.base.BaseActivity;
import com.cbgolf.oa.util.DataUtil;
import com.cbgolf.oa.util.DateUtil;
import com.cbgolf.oa.util.TextUtil;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by lq on 2017/9/5.
 */

public class CouponPushSuccessActivity extends BaseActivity {

    //top
    @ViewInject(R.id.topBack_ll)
    private View topBack;
    @ViewInject(R.id.title_tv)
    private TextView topTitle;
    @ViewInject(R.id.topRight_tv)
    private TextView topRightTv;
    //body
    @ViewInject(R.id.coupon_push_success_num_tv)
    private TextView numTv;
    @ViewInject(R.id.coupon_push_success_type_tv)
    private TextView typeTv;
    @ViewInject(R.id.coupon_push_success_parkname_tv)
    private TextView parkNameTv;
    @ViewInject(R.id.coupon_push_success_lowest_tv)
    private TextView lowestTv;
    @ViewInject(R.id.coupon_push_success_usetime_tv)
    private TextView useTimeTv;
    @ViewInject(R.id.coupon_push_success_tip_tv)
    private TextView tipTv;
    //var
    private String parkName;
    private String moneyNum;
    private String lowestNum;
    private long startTime;
    private long overTime;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.a_coupon_push_success);
    }

    @Override
    protected void findViews() {
        x.view().inject(this);
    }

    @Override
    protected void setViews() {
        topTitle.setText("发布成功");
        tipTv.setText("发布成功");
        topBack.setVisibility(View.GONE);
        topRightTv.setText("关闭");
        topRightTv.setVisibility(View.VISIBLE);
        Intent intent = getIntent();
        startTime = DataUtil.getLongExtra(intent, "startTime", -1);
        overTime = DataUtil.getLongExtra(intent, "overTime", -1);
        moneyNum = DataUtil.getStringExtra(intent, "moneyNum");
        lowestNum = DataUtil.getStringExtra(intent, "moneyLimit");
        numTv.setText(moneyNum);
        typeTv.setText("球场券");
        parkName = DataUtil.getCourseName();
        parkNameTv.setText(TextUtil.Text(parkName));
        lowestTv.setText("1.订场满" + TextUtil.textNumFloat(lowestNum) + "元可使用");
        useTimeTv.setText("2.有效期" + (-1 == startTime ? ""
                : DateUtil.stampToDateyMd2(String.valueOf(startTime)))
                + "-" + (-1 == overTime ? "" : DateUtil.stampToDateyMd2(String.valueOf(overTime))));
    }

    @Override
    protected void setListener() {
        topRightTv.setOnClickListener(v -> {
            mStartActivity(MainActivity.class);
            finish();
        });
    }

    @Override
    protected void onKeyBack() {
        mStartActivity(MainActivity.class);
        super.onKeyBack();
    }
}
